var app = angular.module('stockrecommendList', []);
app.controller('listController', function ($scope,$http) {
    getData();
    $scope.addType = "";
    function getData() {
        $http.get("/smtool_project/api/stockrecommend/getStockRecommendList",{
            params: {
                "actionType":"stockrecommend",
                "isRecommend":"1",
                "enable":"1",
                "addType":$scope.addType,
                "queryStr":$scope.queryStr
            }
        }).then(function (result) {
            $scope.datas = result?result.data.mconferencelist:"";
            $scope.stockVals = result?result.data.stockVals:"";
            $scope.nums = new Array($scope.datas.length);

        });
    };

    $scope.allData = function(addType) {
        $scope.addType = addType||'';
        getData(addType);
    };

    $scope.toDetail = function(rowId) {
        location.href="../stockrecommend/stockrecommenddetail?rowId="+rowId;
    };
});
app.filter('getRealPercent',function(){
    return function(val,importPrice) {
        var realRate = getRealRate(importPrice, val);
        return toDecimal(realRate) + "%";
    }
    function getRealRate(importPrice, realPrice) {
        return (realPrice - importPrice) * 100 / importPrice
    };

    function toDecimal(x) {
        var f = parseFloat(x);
        if (isNaN(f)) {
            return;
        }
        f = Math.round(x * 100) / 100;
        return f;
    };
})
